package two.chapter_1.c1_4;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

import java.util.Arrays;

public class DoublingTest {

    public static double timeTrial(int N){
        int MAX=1000000;
        int []a=new int[N];
        for (int i=0;i<N;i++){
            a[i]=StdRandom.uniform(-MAX,MAX);
        }
        Arrays.sort(a);
        Stopwatch timer=new Stopwatch();
        //int cnt=TwoSum.twoSum(a);
        TwoSum.twoSumFastSorted(a);
        return timer.elapseTime();
    }

    public static void main(String[]args){
        for (int N=250;true;N+=N){
            double time=timeTrial(N);
            StdOut.println( String.format("%7d %5.1f\n",N,time));
        }
    }
}
